package com.asm.DBloader;

import java.util.ArrayList;

import android.R.string;
import android.app.Fragment;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

import com.asm.DBloader.ASM_DB;
import com.asm.DBloader.ASM_FdebtorDS;
import com.asm.DBloader.ASM_fCompanySettingDS;

public class ASM_RefNoGenarator
{
	private SQLiteDatabase dB;
	private ASM_DB dbHelper;
	private Context context;
	//private Context _context;
	public static String kk;
	
	public ASM_RefNoGenarator(Context context)
	{
		this.context = context;
		dbHelper = new ASM_DB(context);
	}
	
	public void open() throws SQLException
	{
		dB = dbHelper.getWritableDatabase();
	}
	
	public String getFcompanyDetails(String cSettingsCode,String ASMname) 
	{
		String number,cCharVal = null,ASMPreFix = null;
		
		if (dB == null) 
		{
			open();
		} else if (!dB.isOpen()) {
			open();
		}
	
		String selectQuery = "select cCharVal from fCompanySetting where cSettingsCode = '"+cSettingsCode+"'";
		
		Cursor cursor = null;
		cursor = dB.rawQuery(selectQuery, null);
		
		while(cursor.moveToNext())
		{
		 cCharVal = cursor.getString(0);
		}
		
		
		String selectQuery1 = "select ASMPreFix from fASM where ASMCode = '"+ASMname+"' ";
		
		Cursor cursor1 = null;
		cursor1 = dB.rawQuery(selectQuery1, null);
		
		while(cursor1.moveToNext())
		{
		 ASMPreFix = cursor.getString(0);
		}
		
		
		
		number = cCharVal + ASMPreFix;
		
		
		kk = number;
		
		return number;
		
		
	}
	

}
